7fc77d55cb6a596ff07df05c816cc2ca3b24a8df,src/edu/stanford/nlp/util/StringUtils.java,StringUtils,argsToPropertiesWithResolve,#String[]#,1814

Before Change


        else
          key = key.substring(1); // strip off the hyphen
        if (key.equalsIgnoreCase(PROP) || key.equalsIgnoreCase(PROPS) || key.equalsIgnoreCase(PROPERTIES) || key.equalsIgnoreCase(ARGUMENTS) || key.equalsIgnoreCase(ARGS)) {
          result.putAll(propFileToTreeMap(args[i + 1]));
          i++;
        }

After Change


   */
  public static Properties argsToPropertiesWithResolve(String[] args) {
    TreeMap<String, String> result = new TreeMap<String, String>();
    Map<String, String> existingArgs = new TreeMap<String, String>();
    for (int i = 0; i < args.length; i++) {
      String key = args[i];
      if (key.length() > 0 && key.charAt(0) == '-') { // found a flag
        if (key.length() > 1 && key.charAt(1) == '-')
          key = key.substring(2); // strip off 2 hyphens
        else
          key = key.substring(1); // strip off the hyphen

        int max = 1;
        int min = 0;
        List<String> flagArgs = new ArrayList<String>();
        // cdm oct 2007: add length check to allow for empty string argument!
        for (int j = 0; j < max && i + 1 < args.length && (j < min || args[i + 1].length() == 0 || args[i + 1].charAt(0) != '-'); i++, j++) {
          flagArgs.add(args[i + 1]);
        }
        if (flagArgs.isEmpty()) {
          existingArgs.put(key, "true");
        } else {
          
          if (key.equalsIgnoreCase(PROP) || key.equalsIgnoreCase(PROPS) || key.equalsIgnoreCase(PROPERTIES) || key.equalsIgnoreCase(ARGUMENTS) || key.equalsIgnoreCase(ARGS)) {
            result.putAll(propFileToTreeMap(join(flagArgs," "), existingArgs));
            i++;
            existingArgs.clear();
          } else
            existingArgs.put(key, join(flagArgs, " "));
        }
      }
    }
    result.putAll(existingArgs);
    
    for (Entry<String, String> o : result.entrySet()) {
      String val = resolveVars(o.getValue(), result);